﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report_Stock_Amount_View.aspx.cs" Inherits="JKF.Web.Report.Report_Stock_Amount_View" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>财富分析库存统计分析</title>
    <script src="/js/jquery.js" type="text/javascript"></script> 
        <%= RegScript("~/js/jquery.1.5.js")%>
         <%= RegScript("~/js/jquery.js")%> 
        <%= RegScript("~/js/jquery.nhis.js")%>
        <%= RegScript("~/js/jquery.rchis.js")%>
        <%= RegScript("~/js/jquery-ui-custom.min.js")%>
        <%= RegScript("~/js/css.js")%>
        <%= RegScript("~/js/DatePicker/WdatePicker.js")%>
        <%= RegScript("~/js/Common.js")%>
        <%= RegScript("~/js/Jquery.commonGrid.js")%>
        <script src="/js/Uppop/tipswindown2.js"  type="text/javascript"></script>
    <link href="/App_Themes/Theme2/Include.css"   rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        var product_keys = ''; // 选择的产品的ID
        $(function () {
            //注册选择产品分类/产品名称的单击事件  
            $('#txt_product_NAME').click(function () {
                product_keys = ''; //清空查询条件
                window.parent.pop("选择产品类别/产品名称", '<%= ResolveUrl("~/Stock/Stock_View_Product_Sort_Tree.aspx") %>', 300, 300, getSelectProduct_Sort);
            });

        });


        //获取选中节点
        function getSelectProduct_Sort(treeObj, id) {
            product_keys = '';
            $('#txt_type_product').val('选择/修改');
            if (treeObj.length > 0) {
                var check_three_nodes_id = '';
                var check_three_nodes_name = '';
                for (var i = 0; i < treeObj.length; i++) {
                    check_three_nodes_id += treeObj[i].ID + ',';
                    check_three_nodes_name += treeObj[i].NAME + ',';
                }
                product_keys = check_three_nodes_id.substr(0, check_three_nodes_id.length - 1);
                check_three_nodes_name = check_three_nodes_name.substr(0, check_three_nodes_name.length - 1);
                $('#txt_product_NAME').val(check_three_nodes_name).attr('title', check_three_nodes_name);
            }
        }
    </script>
    <script type="text/javascript">
        var AppPath = '<%=AppPath %>';
        var handler = AppPath + '/do/Stock/Stock_Amount.do';
        var shops = <%=Shops%>;
        var PageSize = 10;
        var pager = null;
        $(function () {
            // 组织查询条件
            var searchData = { ActionName: 'GetStock_Amounts',
                PRODUCT_KEY: '', // 产品名称ID
                MODEL: $('#txt_product_model').val(),
                PageIndex: 1, PageSize: 10,
                ownShop:$.FxNull($("#ownShop").attr("codes"), "")
            };
            pager = $('#divPager').pager(AppPath, handler, function () {
                return searchData;
            }, function (data) {
                var tbody = $('#tb tbody');
                tbody.empty();
                if (data && data.Entity && data.Entity.length) {
                    data = data.Entity;
                    var tr, td;
                    for (var i = 0; i < data.length; i++) {
                        var item = data[i];
                        tr = $("<tr key=" + item.PRODUCT_KEY + "></tr>").appendTo(tbody);

                        //rk_content="' + item.PRODUCT_KEY + "|" + item.SHOP_CODE + '"
                        $('<td></td>').appendTo(tr).html('<input rk_product_name="' + item.NAME + '" rk_product_key="' + item.PRODUCT_KEY + '"  class="btn_style" type="button" value="查看入库明细" /><input value="查看出库明细"  class="btn_style"  type="button"    ck_product_name="' + item.NAME + '"    ck_product_key="' + item.PRODUCT_KEY + '" />');
                        $('<td></td>').appendTo(tr).text(item.SORT_NAME); // 产品类别
                        $('<td></td>').appendTo(tr).text(item.NAME); // 产品名称
                        $('<td></td>').appendTo(tr).text(item.MODEL); // 规格/型号
                        $('<td></td>').appendTo(tr).text(item.PRODUCT_NUMS); // 库存数量
                    }
                    //入库明细跳转
                    $('#tb').find('input[value=查看入库明细]').click(function () {
                        window.parent.goPage('In/Stock_In_View.aspx产品入库', '.RibbonZoneContent div[title=\'产品入库\']', '&rk_product_name=' + $(this).attr('rk_product_name') + '&rk_product_key=' + $(this).attr('rk_product_key'));
                    });
                    //出库明细跳转<a href="Out/Stock_Out_View.aspx">Out/Stock_Out_View.aspx</a>
                    $('#tb').find('input[value=查看出库明细]').click(function () {
                        window.parent.goPage('Out/Stock_Out_View.aspx产品出库', '.RibbonZoneContent div[title=\'产品出库\']', '&ck_product_name=' + $(this).attr('ck_product_name') + '&ck_product_key=' + $(this).attr('ck_product_key'));
                    });
                } else {
                    tbody.html('<tr id="emptyTr"><td colspan="9" style="text-align: center">没有数据!</td></tr>');
                }
                //这里动态获取高度
                //var tbHeight = $(window).height() - $(".common_search").height() - $("#divPager").height() - 70;
                var tbHeight = $(window).height() - $(".common_search").height() - $("#divPager").height() - 38;
                tbHeight = tbHeight < 300 ? 300 : tbHeight;
                $("#tb").H8_Grid($("#divPager"), tbHeight);
            }, PageSize, true);

            // 查询
            $('#btn_search').click(function () {
                searchData.MODEL = $('#txt_product_model').val();
                // 获取产品类别/产品名称ID
                searchData.PRODUCT_KEY = product_keys;
                searchData.ownShop = $.FxNull($("#ownShop").attr("codes"), "");
                pager.option.pageIndex = 1;
                pager.getPegerData();
                return false;
            });
            //注册选择店铺，如果是总店或者区域经理
            $("#ownShop").MgrShopSelect(AppPath, shops);
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="warrper_body"> 
        <!--隐藏域中保存当前虚拟路径以便发送ajax异步请求时用-->
        <input id="AppPath" name="AppPath" type="hidden" value="<%=AppPath%>" />
         <div class="index" style=" overflow:hidden">
            <div class="common_search">
                 <div class="l_h45">  
                   产品名称：<input type="button" id="txt_product_NAME" class="common_btn_gaoji115" value="选择/修改"/>
                   型号/规格：<input type="text" id="txt_product_model" value="" />
                      <span class="mr30 mb20">所属店铺：
                        <input type="button" id="ownShop" class="common_btn_gaoji115" />
                    </span>
                    <span class="mr30"><input name="" id="btn_search" type="button"  class="common_btn_search"/></span>
                    
                 </div>
            </div>
            <div class="l_h7"></div>
           
            <div class="index_table"  >
                <table id="tb" width="100%" class="common_table">
                    <thead>
                        <tr>
                            <th width="100px" orderaction="false">操作</th>
                             <th width="150px" ordertype="string">产品类别</th>
                            <th width="100px" ordertype="string">产品名称</th>
                             <th width="100px" ordertype="string">型号/规格</th>
                            <th width="150px" ordertype="string">库存数量</th>
                            
                        </tr>
                    </thead>
                    <tbody>
                        
                        <tr>
                            <td colspan="8" style="text-align: center">点击搜索查看数据</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="page" id="divPager"></div>      
        </div>
    </div>
    </form>
</body>
</html>
